/**
 * 
 */
package edu.scsu.csci.core;

import java.io.Serializable;

/**
 * @author Maqbool Khan.
 * @viz.diagram FrameWorkCheckedException.tpx
 *
 */
public abstract class FrameWorkCheckedException extends Exception implements Comparable<FrameWorkCheckedException>, Serializable
{
	 /**
     * class serialization id.
     */
    private static final long serialVersionUID = 9624571233476147L;
    
    /**
     * Indicates whether the stack trace has been printed or not.
     */
    private boolean stackTarcedPrinted = false;
    
    /**
     * Creates a new FrameWorkUncheckedException.
     */
    public FrameWorkCheckedException() { }
    
    /**
     * Creates a new FrameWorkUncheckedException.
     * @param exceptionMessage	The cuase for the exception.
     */
    public FrameWorkCheckedException(String exceptionMessage) {
        super(exceptionMessage);
    }
    
    /**
     * Creates a new FrameWorkUncheckedException.
     * @param e					The actual exception object.
     */
    public FrameWorkCheckedException(Throwable e)   {
        super(e);
    }
    
    /**
     * Creates a new FrameWorkUncheckedException.
     * @param exceptionMessage	The cuase for the exception.
     * @param e					The actual exception object.
     */
    public FrameWorkCheckedException(String exceptionMessage, Throwable e)   {
        super(exceptionMessage, e);
    }
    
     /**
     * Returns a string containing the exception message for this object along with the orignal cause's exception message.
     * @return
     */
    public String getComprehensiveMsg()   {
        return ((this.getCause() == null) ? super.getMessage(): super.getMessage() + "\nCause: " + this.getCause().getMessage()); 
    }
        
     /** 
     * Compares based on the exception message.
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */  
    public int compareTo(FrameWorkCheckedException o) {
    	return ( this.getMessage() == null ?  (o.getMessage() == null ? 0 : -1) : (o.getMessage()  == null ? 1 : this.getMessage().toUpperCase().compareTo(o.getMessage().toUpperCase())));
    }
    
        
    /* (non-Javadoc)
	 * @see java.lang.Throwable#printStackTrace()
	 */
	public synchronized void printStackTrace()	{
		if(!this.stackTarcedPrinted)
		{
			super.printStackTrace();
			this.stackTarcedPrinted = true;
		}
	}
}
